#ifndef PERSPECTIVEVIEWWIDGET_H
#define PERSPECTIVEVIEWWIDGET_H

#include <QDialog>
class StudyRecord;

#import "mil9/mil.ocx" no_namespace
#import "mil9/MILImageProcessing.ocx" no_namespace

namespace Ui {
class PerspectiveViewWidget;
}

class PerspectiveViewWidget : public QDialog
{
    Q_OBJECT

public:
    explicit PerspectiveViewWidget(QWidget *parent = 0);
    ~PerspectiveViewWidget();

signals:
    void savePerspectImage(const QByteArray &pixels, int count, int width, int height,
                           double winCenter, double winWidth, bool newSeries = false);
    void decKv();
    void incKv();

public slots:
    void onMultiFrameSaved(bool);
    void startView(bool yes);
    void markFrame();
    void generateLutRamps();
    void onZoom(double factor);
    void onException(int code, const QString &source, const QString &desc, const QString &help);

    // COM Event handlers
    void onProcessModifiedImage(int index);

protected:
    void resizeEvent(QResizeEvent *e);

private:
    void init();
    void setupConnections();
    void saveMultiFrames();

    Ui::PerspectiveViewWidget *ui;

    IApplicationPtr pApp;
    ISystemPtr pSys;
    IDigitizerPtr pDig;
    IImagePtr pImgDest;
    IImageProcessingPtr pImgPro;
    IDisplayPtr pDis;
    IGraphicContextPtr pGC;
    IImagePtr pImgSum;
    QVector<IImagePtr> images;
    QVector<IImagePtr> avgImages;
    QByteArray pixelData;
    long numOfFrames;
    long numOfSavingFrames;
    bool saveLater;
    int delay;
};

#endif // PERSPECTIVEVIEWWIDGET_H
